package com.cg.controller;


import com.cg.dto.*;
import com.cg.entity.Work;
import com.cg.result.R;
import com.cg.service.IVideoService;
import com.cg.service.IWorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 作品 前端控制器
 * </p>
 *
 * @author 加
 * @since 2025-01-17
 */
@RestController
@CrossOrigin
@RequestMapping("/api/work")
@Api(value = "workController",description = "欢迎来到绣品管理",tags = "绣品管理")
public class WorkController {
    @Autowired
    private IWorkService workService;

    @ApiOperation("根据绣品名称查询绣品")
    @PostMapping("selectWorkByName")
    public List<Work> selectWorkByName(@RequestParam("workName") String workName){
        return workService.selectWorkByName(workName);
    }


    @ApiOperation("新增绣品")
    @PostMapping("/addWork")
    public R addWork(@Validated @RequestBody AddWorkDTO addWorkDTO ){
        return workService.addWork(addWorkDTO);
    }

    @ApiOperation("修改绣品信息")
    @PutMapping("/updateWork")
    public R updateWork(@Validated @RequestBody UpdateWorkDTO updateWorkDTO ){
        return workService.updateWork(updateWorkDTO);
    }

    @ApiOperation("删除绣品")
    @DeleteMapping("/deleteWork")
    public R deleteWork(@RequestParam("workId") Long workId){
        return workService.deleteWork(workId);
    }



    @ApiOperation("条件查询作品")
    @PostMapping("getWorkByCondition")
    public R<List<Work>> getWorkByCondition(@Validated @RequestBody SearchWorkDTO searchWorkDTO){
        return workService.getWorkByCondition(searchWorkDTO);
    }

    @ApiOperation("新增收藏")
    @PostMapping("addLike")
    public R addLike(AddLikeDTO addLikeDTO){
        return workService.addLike(addLikeDTO);
    }

}
